package packets.client;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;

import packets.Packet;

/**
 * a data structure that contains a user's registration informatino
 * used to be sent in a {@link Packet}
 */
public class Registration implements Serializable{

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private String _name;
	private String _bday;
	private String _country;
	private String _city;
	private String _password;
	private byte[] _img;

	/**
	 * Creates an instance of Registration
	 * @param name user's name
	 * @param pw user's password (encrypted)
	 * @param bday user's birthday
	 * @param country user's country
	 * @param city user's city
	 * @param img the file that contains the user's image
	 * @throws FileNotFoundException if the file entered does not exist
	 * @throws IOException if there was an error reading from the file
	 */
	public Registration(String name , String pw, String bday, String country, String city, File img) throws FileNotFoundException, IOException{
		_name = name;
		_bday = bday;
		_country = country;
		_city = city;
		_password = pw;
		//picture up to 6k
		FileInputStream fis = new FileInputStream(img);
		_img = new byte[(int)img.length()];
		fis.read(_img);
		
	}

	/**
	 * 
	 * @return the user's name
	 */
	public String getName() {
		return _name;
	}

	/**
	 * 
	 * @return the user's birthday
	 */
	public String getBday() {
		return _bday;
	}

	/**
	 * 
	 * @return the user's country
	 */
	public String getCountry() {
		return _country;
	}

	/**
	 * 
	 * @return the user's city
	 */
	public String getCity() {
		return _city;
	}

	/**
	 * 
	 * @return the user's password
	 */
	public String getPassword() {
		return _password;
	}
	
	/**
	 * 
	 * @return a byte array containing the user's picture
	 */
	public byte[] getPicture(){
		return _img;
	}

}
